<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'add_executive_master.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<script src="Scripts/mfcrm_js.js" type="text/javascript"></script>
	<script src="Scripts/box.js" type="text/javascript"></script>
	<link href="Styles/box.css" rel="stylesheet" type="text/css" />
	<link href="Styles/mfcrm_styles.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
      function Location_list() {
     
                    var url = "getLocationAction";
   
                    if (typeof XMLHttpRequest != "undefined") {
                        req = new XMLHttpRequest();
                    } else if (window.ActiveXObject) {
                        req = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    req.open("GET", url, true);
   
                    req.onreadystatechange = callback_Location;
                    req.send(null);
  
                }

                function callback_Location() {
                    if (req.readyState == 4) {
                        if (req.status == 200) {
                        var name= document.getElementById("po_location");
                        var breakStr=req.responseText;
                        var temp=new Array();
                        temp=  breakStr.split(':');
                        name.options.length = 0; // clear out existing items
                        for(i=0; i <temp.length-1;i++)
                        {
                            var opt = document.createElement('option');
                            opt.text = temp[i];
        
                            try
                            {
                                name.add( opt, null );						
                            }
                            catch(ex)
                            {
                                name.add( opt );		
                            }	
                   
                        }											
        
            
                        }

                    }
                }
          function GetTeamLeader() {
                    var Location_ID = document.getElementById("po_location").value;
     
                    var url = "getTeamLeaderAction_EXEC?location_id="+Location_ID;
           
                    if (typeof XMLHttpRequest != "undefined") {
                        req = new XMLHttpRequest();
                    } else if (window.ActiveXObject) {
                        req = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    req.open("GET", url, true);
   
                    req.onreadystatechange = callback_TeamLeader;
                    req.send(null);
  
                }

                function callback_TeamLeader() {
                    if (req.readyState == 4) {
                        if (req.status == 200) {
                        var name= document.getElementById("tl_name");
                        var breakStr=req.responseText;
                        var temp=new Array();
                        temp=  breakStr.split(':');
                        name.options.length = 0; // clear out existing items
                        for(i=0; i <temp.length-1;i++)
                        {
                            var opt = document.createElement('option');
                            opt.text = temp[i];
        
                            try
                            {
                                name.add( opt, null );						
                            }
                            catch(ex)
                            {
                                name.add( opt );		
                            }	
                   
                        }											
        
            
                        }

                    }
                }
                
                function  GetTL_ID()
             {
                var idField = document.getElementById("po_location").value;
                var idyear= document.getElementById("tl_name").value;
                
          
                   var url = "getTeamLeaderIDAction?location_action=" +idField+"&tl_name_action="+idyear;
   
                    if (typeof XMLHttpRequest != "undefined") {
                        req = new XMLHttpRequest();
                    } else if (window.ActiveXObject) {
                        req = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    req.open("GET", url, true);
   
                    req.onreadystatechange = callback_executive_id_value;
                    req.send(null);
             }
           function callback_executive_id_value() {
   
                    if (req.readyState == 4) {
                        if (req.status == 200) {
                        var breakStr=req.responseText;
                        var temp=new Array();
                        temp=  breakStr.split(':');
                        var suppoa=temp[0];
                       // alert(suppoa);
                        var suppoa1=temp[1];
                        //alert(suppoa1);
                       document.getElementById("tl").value=suppoa;
                        }
                        }
                        }
function check_emplty()
{
      
if(stock_data.po_location.value=="Select Location")
{
alert("Please Select Location");
return false;
} 
if(stock_data.tl_name.value=="Select Team Leader")
{
alert("Please Select Team Leader");
return false;
}
if(stock_data.exe_name.value=="")
{
alert("Please Enter Executive Name");
return false;
} 
if(stock_data.login_id.value=="")
{
alert("Please Enter User ID");
return false;
} 
if(stock_data.password.value=="")
{
alert("Please Enter Password");
return false;
} 
if(stock_data.exe_email_id1.value=="")
{
alert("Please Enter Email ID");
return false;
} 
if(stock_data.exe_email_id1.value.length > 1)
{
temp=verifyEmail();
	    if(!temp)
	    {
	   	return false;
	  		}
}
if(stock_data.exe_cont_no1.value=="")
{
alert("Please Enter Executive Contact No");
return false;
} 
}



function verifyEmail()
{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(stock_data.exe_email_id1.value))
		{
			return (true);
		}
		alert("Please Enter valid Email Id.");
		stock_data.exe_email_id1.value="";
		stock_data.exe_email_id1.focus();
		return (false);
	
  }
function VarifyMobile()
{
   var checkChar = '0123456789+-';
   var nameValue = stock_data.exe_cont_no1.value;
   var Rname='';
   for(j=0 ; j < nameValue.length ; j++)
   	{
                    if (nameValue.length>10)
		  		  		       {
		  		  		       		 alert("Enter 10 Digit Mobile No.");
		  		  		       		 return false;
		                       }
		            if (checkChar.indexOf(nameValue.charAt(0)) == 9 || checkChar.indexOf(nameValue.charAt(0)) == 8 || checkChar.indexOf(nameValue.charAt(0)) == 7)
		  		       		 {  
		  		       		  }else{
		  		       		  alert("Enter Mobile No. start with 9,8 or 7.");
		  		       		  stock_data.exe_cont_no1.value=Rname;
		  		       		      
		  		       		  return false;
                            }
                  if (checkChar.indexOf(nameValue.charAt(j)) == -1)
     		       {
					  alert("Enter Numaric Value Only");
					  stock_data.exe_cont_no1.value=Rname;
					  return false;
                   }
                        Rname = Rname+nameValue.charAt(j)
   }
      return true;
}
</script>
  </head>
  
  <body onload="Location_list();">
<s:form action="insert_executive_master" method="post" name="stock_data" theme="css_xhtml" onsubmit="return check_emplty();">
<table border="0" cellpadding="0" cellspacing="0" align="left" width="100%">
<tbody>
<tr>
<td width="100%" height="38" valign="middle" align="left" bgcolor="#ff7519" >Add New Executive Form:</td>
</tr>
			<tr>
				<td >
				<table  class="obox" cellpadding="0" width="100%">
					<tbody>
					<tr>
						       <tr bgcolor="#ffffff">
						        <td nowrap="nowrap" bgcolor="#530053" style="font-family: &#39;Courier New&#39;, Courier, monospace; font-size: small; color: #FFFFFF; font-style: normal; text-transform: capitalize" align="center" colspan="4"></td>
						        <td class="style5" colspan="4" bgcolor="#530053" style="font-family: &#39;Courier New&#39;, Courier, monospace; font-size: small; color: #FFFFFF; font-style: normal; text-transform: capitalize" align="center"></td>
					          </tr>
					          <tr bgcolor="#ffffff">
                              
                                 <td class="style5">Location : <span style="color:Red;font-size:Medium;display:none;">*</span>
                                 </td>
                                  
						        <td class="style2">
                                 <s:select  list="# {'':'Select Location'}" name="location_id" id="po_location" onfocus="Location_list();" onchange="GetTeamLeader();" style="width:100px;" tabindex="1"/>
                                </td>
						         <td class="style1">TL : <span style="color:Red;font-size:Medium;display:none;">*</span>
                                  </td>
                                 <td nowrap="nowrap" class="style1">
                                  <input name="tl" type="hidden" id="tl" title="Please Press Tab" >
                                  <s:select  list="# {'':'Select Team Leader'}" name="tl_name" id="tl_name" onchange="GetTL_ID();" style="width:100px;" tabindex="2"/>
                                </td>             
						        <td class="style1">Executive Name:<span style="color:Red;font-size:Medium;display:none;">*</span>
                                  </td>
                                <td nowrap="nowrap" class="style1">
                                 <input name="exe_name"  type="text" tabindex="3" style="width:100px;"> 
                                </td>
                                
					          </tr>
					           <tr bgcolor="#ffffff">
						        <td nowrap="nowrap" bgcolor="#530053" style="font-family: &#39;Courier New&#39;, Courier, monospace; font-size: small; color: #FFFFFF; font-style: normal; text-transform: capitalize" align="center" colspan="4"></td>
						        <td class="style5" colspan="4" bgcolor="#530053" style="font-family: &#39;Courier New&#39;, Courier, monospace; font-size: small; color: #FFFFFF; font-style: normal; text-transform: capitalize" align="center"></td>
					          </tr>
					           <tr bgcolor="#ffffff">
                              
                                <td class="style1">User ID:<span style="color:Red;font-size:Medium;display:none;">*</span>
                                  </td>
                                <td nowrap="nowrap" class="style1">
                                 <input name="login_id"  type="text" tabindex="4" style="width:100px;"> 
                                </td>
						        <td class="style1">Password:<span style="color:Red;font-size:Medium;display:none;">*</span>
                                  </td>
                                <td nowrap="nowrap" class="style1">
                                 <input name="password"  type="text" tabindex="5" style="width:100px;"> 
                                </td>           
						        <td class="style1">Email ID:<span style="color:Red;font-size:Medium;display:none;">*</span>
                                  </td>
                                <td nowrap="nowrap" class="style1">
                                 <input name="exe_email_id1"  type="text" tabindex="6" style="width:100px;"> 
                                </td>
                                
					          </tr>
					          <tr bgcolor="#ffffff">
						        <td nowrap="nowrap" bgcolor="#530053" style="font-family: &#39;Courier New&#39;, Courier, monospace; font-size: small; color: #FFFFFF; font-style: normal; text-transform: capitalize" align="center" colspan="4"></td>
						        <td class="style5" colspan="4" bgcolor="#530053" style="font-family: &#39;Courier New&#39;, Courier, monospace; font-size: small; color: #FFFFFF; font-style: normal; text-transform: capitalize" align="center"></td>
					          </tr>
					           <tr bgcolor="#ffffff">
                              
                               <td class="style1">Contact No:<span style="color:Red;font-size:Medium;display:none;">*</span>
                                  </td>
                                <td nowrap="nowrap" class="style1">
                                 <input name="exe_cont_no1"  type="text" tabindex="7" style="width:100px;"> 
                                </td>
						        <td class="style1"><span style="color:Red;font-size:Medium;display:none;">*</span>
                                  </td>
                                <td nowrap="nowrap" class="style1" style="width:100px;">
                               
                                </td>           
						        <td class="style1"><span style="color:Red;font-size:Medium;display:none;">*</span>
                                  </td>
                                <td nowrap="nowrap" class="style1" style="width:100px;">
                                
                                </td>
                                
					          </tr>
					          </tbody>
					          </table>
					          </td>
                             </tr>
                             <tr>
                             <td>
                              <br>
                             <br>
                             </td>
                             </tr>
                             <tr valign="middle">
                            
						       <td class="orgbg" colspan="10" align="center">
                                 <input type="submit" name="Button1" value="CONFIRM"  id="Button1" tabindex="66" class="btn"  onclick="return check_emplty();">
						          &nbsp;
                                  <input type="reset" name="Button2" value="RESET" id="Button2" tabindex="67" class="btn">
                                </td>
					          </tr>
</tbody>
</table>
</s:form>
  </body>
</html>
